package com.airlines.basedata.controller;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
import com.airlines.basedata.service.BasRankService;
/**
 * 
 * @Description:机上岗位Controller层
 * @author ouwen
 * @Date 2018年9月18日
 */
@Controller
@RequestMapping("/basrank")
public class BasRankController {

	/**
	 * 机上岗位view prefix
	 */
	private final String PREFIX = "/basedata/basrank";
	
	/**
	 * 机上岗位Service接口
	 */
	@Resource
	private BasRankService basRankService;
	/**
	 * 机上岗位页面
	 * @return view index
	 */
	@RequestMapping("")
	public ModelAndView index() {
		return new ModelAndView(PREFIX+"/index");
	}
	
	/**
	 * 条件查询数据列表
	 * @param SchMatch query
	 * @param offset
	 * @param limit
	 * @return
	 */
	/*@RequestMapping(value = "/list.do", method = POST)
	@ResponseBody
	public Page list(SchMatch schMatch, String offset, String limit) {
		Page page = new Page();
		page.setPageNumber((Integer.valueOf(offset) / (Integer.valueOf(limit))));
		page.setPageSize(Integer.valueOf(limit));
		page = schMatchService.list(schMatch, page);
		return page;
	}*/
	
	/**
	 * 添加页面
	 * @return
	 */
	@RequestMapping(value = "/add.do", method = GET)
	@ResponseBody
	public ModelAndView add() {
		return new ModelAndView(PREFIX + "/add");
	}

	/**
	 * 数据库新增一个数据
	 * @param SchMatch
	 * @param request
	 * @return
	 */
  /*@RequestMapping(value = "/save.do", method={ RequestMethod.POST})
    @ResponseBody
    public R save(SchMatch schMatch, HttpServletRequest request){
    	schMatch.setIsDelete("1");
    	schMatch.setId(UUIDUtils.uuid());
    	schMatch.setOper("admin");
    	schMatch.setOperIp(IpUtils.getIpFromRequest(request));
    	String operHost = " ";
    	try {
    		operHost = InetAddress.getLocalHost().getHostName();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} 
    	schMatch.setOperHost(operHost);
    	schMatch.setOpTime(new Date());
        if(schMatchService.insertOne(schMatch) == 1) {
            return R.ok();
        }
        return R.error();
    }*/
    
    /**
     * 编辑页面跳转
     * @param id
     * @return
     */
    /*@RequestMapping(value = "/edit", method=GET)
    public ModelAndView edit(String id){
        Schconflict schconflict = schconflictService.getConflictById(id);
        ModelAndView mv = new ModelAndView(PREFIX + "/edit");
        mv.addObject("schconflict", schconflict);
        System.out.println(schconflict);
        return mv;
    }*/
    
    /**
     * 执行更新操作
     * @param schconflict
     * @param request
     * @return
     */
    /*@RequestMapping(value = "/update.do", method=POST)
    @ResponseBody
    public R update(Schconflict schconflict, HttpServletRequest request){
    	schconflict.setIsDelete("1");
    	schconflict.setOper("admin");
    	schconflict.setOperIp(IpUtils.getIpFromRequest(request));
    	String operHost = " ";
    	try {
    		operHost = InetAddress.getLocalHost().getHostName();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} 

    	schconflict.setOperHost(operHost);
    	schconflict.setRemarks(" ");
    	schconflict.setOpTime(new Date());
    	if(schconflictService.updateOne(schconflict) == 1) {
    		return R.ok();
    	}
    	return R.error();
    }
    
    /**
     * 执行删除操作
     * @param id
     * @return
     */
    /*@RequestMapping(value="/delete.do",method=POST)
    @ResponseBody
    public R delete(String id) {
    	if(schconflictService.deleteOne(id) == 1) {
    		return R.ok();
    	}
    	return R.error();
    }*/
}
